From eedc4049fe1f69f9326b6ea4310a1d3d7ab8e0d2 Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Mon, 1 May 2017 20:40:30 +0200 Subject: [PATCH] Add support for cross-compiling, use stable release channel --- debian/control | 4 +++- debian/rules | 29 ++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/debian/control b/debian/control index 05612b4cd..4d89cba47 100644 --- a/debian/control +++ b/debian/control @@ -10,12 +10,14 @@ Build-Depends: debhelper (>= 9.20141010), rustc (>= 1.16), pkg-config, cmake, - cargo (>= 0.7.0) , + cargo (>= 0.13.0) , python-dulwich , python-pytoml , ca-certificates, bash-completion, libcurl4-gnutls-dev | libcurl4-openssl-dev, +# Direct dependency needed for cross-compiling + libstd-rust-dev, libssh2-1-dev, libgit2-dev (>= 0.25.1), libhttp-parser-dev, diff --git a/debian/rules b/debian/rules index e398a8a21..8173942b2 100755 --- a/debian/rules +++ b/debian/rules @@ -5,6 +5,12 @@ include /usr/share/dpkg/architecture.mk include /usr/share/dpkg/buildflags.mk include /usr/share/rustc/architecture.mk +# For cross-compiling; perhaps we should add this to dh-cargo or debcargo +export PKG_CONFIG = $(DEB_HOST_GNU_TYPE)-pkg-config +export PKG_CONFIG_ALLOW_CROSS = 1 +RUSTFLAGS += -C linker=$(DEB_HOST_GNU_TYPE)-gcc + +# Pass on dpkg-buildflags stuff RUSTFLAGS += $(foreach flag,$(LDFLAGS),-C link-arg=$(flag)) export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS RUSTFLAGS @@ -21,7 +27,7 @@ override_dh_auto_configure: ifneq ($(filter pkg.cargo.mkstage0,$(DEB_BUILD_PROFILES)),) # NOTE: this very likely doesn't work any more, see bootstrap.py for details # Instead, you can try to bootstrap by setting PATH to a binary cargo - # downloaded from upstream, or by (TODO) cross-compiling. + # downloaded from upstream; or by cross-compiling, see "build-cross" below # Preserved in case someone wants to resurrect it later: # Bootstrap cargo stage0 ./debian/bootstrap.py \ @@ -45,11 +51,16 @@ endif --disable-debug \ --enable-optimize \ --local-rust-root=/usr \ - --cargo=$(CURDIR)/cargo-stage0 + --release-channel=stable \ + --cargo=$(CURDIR)/cargo-stage0 \ + --build=$(DEB_BUILD_RUST_TYPE) \ + --host=$(DEB_HOST_RUST_TYPE) \ + --target=$(DEB_TARGET_RUST_TYPE) -override_dh_auto_build: - # Build final cargo binary and docs - $(MAKE) +override_dh_auto_build-arch: + RUST_BACKTRACE=1 $(MAKE) + +override_dh_auto_build-indep: ifeq (,$(findstring nodoc,$(DEB_BUILD_PROFILES))) $(MAKE) doc cd target/doc/ && rm -f jquery.js && ln -s /usr/share/javascript/jquery/jquery.js @@ -70,3 +81,11 @@ override_dh_auto_clean: $(CURDIR)/config.stamp \ $(CURDIR)/Makefile \ $(CURDIR)/cargo-stage0 + +build-cross: + DEB_BUILD_OPTIONS=nocheck sbuild --profiles=nocheck \ + --build-failed-commands '%SBUILD_SHELL' \ + --add-depends=libc-dev:$(DEB_HOST_ARCH) \ + $(EXTRA_SBUILD_FLAGS) \ + --host=$(DEB_HOST_ARCH) \ + --no-arch-all . -- 2.30.2